const Storage = {

  clearCookie(key) {
    document.cookie = `${key}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`;
  },
  /**------------------以下代码cookie存储与取值-----------*/
  setCookie(key, value) {
    document.cookie = `${key}=${value}; path=/`;
  },
  getCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(";"); //把cookie分割成组
    for (var i = 0; i < ca.length; i++) {
      var c = ca[i]; //取得字符串
      while (c.charAt(0) == " ") {
        //判断一下字符串有没有前导空格
        c = c.substring(1, c.length); //有的话，从第二位开始取
      }
      if (c.indexOf(nameEQ) == 0) {
        //如果含有我们要的name
        return unescape(c.substring(nameEQ.length, c.length)); //解码并截取我们要值
      }
    }
    return false;
  }
};
export default Storage;
